﻿/*  CamHelper (See http://camhelper.codeplex.com/ or https://bitbucket.org/AndiKS/camhelper for more Info)
    Copyright (C) 2011 Andreas Wimmer

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

using CamHelper.Interpreter;
using NUnit.Framework;

namespace CamHelper.Tests.Interpreter
{
    [TestFixture]
    public class ParameterCollectionTest
    {
        [Test]
        public void AddAndGetParameter()
        {
            var col = new ParameterCollection();
            var p = new Parameter(new ParameterFileLine(null, 1, "# optimization_path		 = 0"));
            col.Add(p);

            var p2 = col[p.UniqueKey];
            Assert.That(p, Is.EqualTo(p2));
        }

        [Test]
        public void BaseParameter()
        {
            var col = new ParameterCollection();
            var p1 = new Parameter(new ParameterFileLine(null, 1, "# optimization_path		 = 1"));
            col.Add(p1);
            var p2 = new Parameter(new ParameterFileLine(null, 2, "# optimization_path		 = 2"));
            col.Add(p2);

            Assert.That(p1, Is.EqualTo(p2.BaseEntry));
        }

        [Test]
        public void CategoryTestOne()
        {
            var col = new ParameterCollection();
            col.Add(new Parameter("cat1", "key1", "value1"));
            col.Add(new Parameter("cat1", "key2", "value2"));

            Assert.That(col.Categories.Count, Is.EqualTo(1));
            Assert.That(col.Categories[0], Is.EqualTo("Cat1"));
        }

        [Test]
        public void CategoryTestTwo()
        {
            var col = new ParameterCollection();
            col.Add(new Parameter("cat1", "key1", "value1"));
            col.Add(new Parameter("cat2", "key2", "value2"));

            Assert.That(col.Categories.Count, Is.EqualTo(2));
            Assert.That(col.Categories[0], Is.EqualTo("Cat1"));
            Assert.That(col.Categories[1], Is.EqualTo("Cat2"));
        }
    }
}
